import * as types from './ActionTypes';
import RemoteClient from '../../network/RemoteClient'

function Arrayf(array) {
  return {
    type: types.ARRAY,
    array: array
  }
}

function Objectf(object) {
  return {
    type: types.OBJECT,
    object: object
  }
}

export function fetchArray(array) {
  return dispatch => {
    let remoteClient = new RemoteClient();
    remoteClient.getJsonArray().then(
      data => {dispatch(Arrayf(data))}
    ).catch(
      error => dispatch()
    )
  }
}

export function fetchObject(object) {
  return dispatch => {
    let remoteClient = new RemoteClient();
    remoteClient.getJsonObject().then(
      data => {dispatch(Objectf(data))}
    ).catch(
      error => dispatch()
    )
  }
}
